package com.edu.tankgame;

import java.util.Vector;

/**
 * //自己的坦克
 */
public class MyHero extends Tank {
    //定义一个shot对象，表示一个射击（线程）
    Shot shot = null;

    //可以发射多颗子弹
    Vector<Shot> shots = new Vector<>();
    public MyHero(int x, int y) {
        super(x, y);
    }

    public void ShotEnemyTank() {
        //创建SHOT
        switch (getDirect()) {
            case 0://上
                shot = new Shot(getX() + 20, getY(), 0);
                break;
            case 1://右
                shot = new Shot(getX() + 60, getY() + 20, 1);
                break;
            case 2://下
                shot = new Shot(getX() + 20, getY() + 60, 2);
                break;
            case 3://左
                shot = new Shot(getX(), getY() + 20, 3);
                break;
        }
        if (shot != null && shots.size() < 5) {
            shots.add(shot);
        }
        new Thread(shot).start();

    }

}
